import type { PersonClearOutput, PersonDto, PersonEditDto, PersonListInput } from './models';
import { RestService, Rest } from '@abp/ng.core';
import type { ListResultDto, PagedResultDto } from '@abp/ng.core';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class PersonService {
  apiName = 'Default';
  

  clearAll = (config?: Partial<Rest.Config>) =>
    this.restService.request<any, PersonClearOutput>({
      method: 'POST',
      url: '/api/app/person/clear-all',
    },
    { apiName: this.apiName,...config });
  

  create = (input: PersonEditDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PersonDto>({
      method: 'POST',
      url: '/api/app/person',
      body: input,
    },
    { apiName: this.apiName,...config });
  

  delete = (id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, void>({
      method: 'DELETE',
      url: `/api/app/person/${id}`,
    },
    { apiName: this.apiName,...config });
  

  exportAll = (config?: Partial<Rest.Config>) =>
    this.restService.request<any, Blob>({
      method: 'POST',
      responseType: 'blob',
      url: '/api/app/person/export-all',
    },
    { apiName: this.apiName,...config });
  

  exportTemplate = (config?: Partial<Rest.Config>) =>
    this.restService.request<any, Blob>({
      method: 'POST',
      responseType: 'blob',
      url: '/api/app/person/export-template',
    },
    { apiName: this.apiName,...config });
  

  get = (id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PersonDto>({
      method: 'GET',
      url: `/api/app/person/${id}`,
    },
    { apiName: this.apiName,...config });
  

  getList = (input: PersonListInput, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PagedResultDto<PersonDto>>({
      method: 'GET',
      url: '/api/app/person',
      params: { filter: input.filter, sorting: input.sorting, skipCount: input.skipCount, maxResultCount: input.maxResultCount },
    },
    { apiName: this.apiName,...config });
  

  importExcel = (file: FormData, config?: Partial<Rest.Config>) =>
    this.restService.request<any, ListResultDto<PersonDto>>({
      method: 'POST',
      url: '/api/app/person/import-excel',
      body: file,
    },
    { apiName: this.apiName,...config });
  

  update = (id: string, input: PersonEditDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PersonDto>({
      method: 'PUT',
      url: `/api/app/person/${id}`,
      body: input,
    },
    { apiName: this.apiName,...config });

  constructor(private restService: RestService) {}
}
